package com.seatch.msauth;

import com.alibaba.cloud.nacos.NacosConfigProperties;
//import com.seatch.msauth.config.SimpleNacosConfigMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;

import java.util.Map;
import java.util.Properties;

//@SpringBootApplication(scanBasePackages ="com.seatch.msauth.*")
@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
public class MsAuthApplication {

    static  ConfigurableApplicationContext context;
//    static  SimpleNacosConfigMap configMap;

//    @Bean
//    public NacosConfigProperties nacosConfigProperties() {
//        NacosConfigProperties nacosConfigProperties = new NacosConfigProperties();
//        nacosConfigProperties.setServerAddr("127.0.0.1:9999");
//        return nacosConfigProperties;
//    }


    public MsAuthApplication(
            Environment env,
            ConfigurableApplicationContext context ) {
        System.out.println("MsAuthApplication initialized");

        String[] activeProfiles = env.getActiveProfiles();


        this.context = context;
//        configMap = configMap;

    }

    public static void main(String[] args) {
//        System.out.println(b);
        // Properties properties = System.getProperties();
//        System.setProperty("spring.cloud.bootstrap.enabled","true");
//        Map<String, String> env = System.getenv();
//        env.put("spring.cloud.bootstrap.enabled","true");
        // Map<String, Object> systemProperties1 = context.getEnvironment().getSystemProperties();
        // systemProperties1.put("spring.cloud.bootstrap.enabled","true");


        SpringApplication.run(MsAuthApplication.class, args);
        MutablePropertySources propertySources = context.getEnvironment().getPropertySources();
        Map<String, Object> systemProperties = context.getEnvironment().getSystemProperties();
//        b = context.getEnvironment().getProperty("a");
//        System.out.println(b);

//        SimpleNacosConfigMap bean = context.getBean(SimpleNacosConfigMap.class);
//        System.out.println( "a => " + bean.getA());
        System.out.println(" .... ");
//        System.out.println( "a => " + bean.getA());
    }




}
